# Copyright (c) 2019 Presto Labs Pte. Ltd.
# Author: leon

import json
import logging
import os

from coin2.support.product_info.futures_bybit_v2 import convert_coin1_constants


pi_file = 'data/coin2/product_info/old_compat/bybit_futures.json'
with open(pi_file) as f:
  static_constants = convert_coin1_constants(json.load(f)['product_infos'])
dynamic_constants = {}
if int(os.getenv('USE_DYNAMIC_SYMBOL', 0)):
  try:
    from coin2.support.product_info.futures_bybit_v2 import gen_coin1_constants
    dynamic_constants = gen_coin1_constants()
  except Exception as e:
    logging.error('Failed to use bybit dynamic symbols! %s', e)

base_currency_list = list(set(
    static_constants.get('base_currency_list', []) +
    dynamic_constants.get('base_currency_list', [])))
quote_currency_list = list(set(
    static_constants.get('quote_currency_list', []) +
    dynamic_constants.get('quote_currency_list', [])))
balance_currency_list = list(set(
    static_constants.get('balance_currency_list', []) +
    dynamic_constants.get('balance_currency_list', [])))

currency_list = list(set(base_currency_list + quote_currency_list))

inverse_symbol_list = list(set(
    static_constants.get('inverse_symbol_list', []) +
    dynamic_constants.get('inverse_symbol_list', [])))

usdt_symbol_list = list(set(
    static_constants.get('usdt_symbol_list', []) +
    dynamic_constants.get('usdt_symbol_list', [])))

active_symbol_list = inverse_symbol_list + usdt_symbol_list
quarter_contract_date = [
    '20210625',
    '20210924',
    '20211231',
]

contract_type_list = ('perpetual', 'quarter', 'next_quarter')
